﻿using System;
using System.Linq;

namespace AIC_Notification
{
    public class StudentStatusReportForAM : StudentStatusReportForAC
    {
        private int City;
        private string CityName;

        public StudentStatusReportForAM(DisplayTable Display)
        {
            ReportTitle = "Student Status (Office)";
            StatisticsLabel = "O";
            ShowStatistics = true;
            ShowURL = true;
            ShowFullTable = Display;
        }

        public override void SendReportAsEmail()
        {
            for (int i = 0; i < CityDB.NoOfCities; i++)
            {
                // Only for office with 1 or more student
                if (CityDB.Cities[i].Students.Count() > 0)
                {
                    string HTMLBody;

                    City = i;
                    CityName = CityDB.GetCityName((CityDB.CityEnum)i);

                    Students = CityDB.Cities[i].Students;
                    RallySchoolStatsList = CityDB.Cities[i].RallySchoolStatsList;
                    RallyOfRallySchoolStats = CityDB.Cities[i].RallyOfRallySchoolStats;
                    HeaderInformation = CityName;

                    FileName = String.Format("{0}-{1}-{2:yyyyMMdd-HHmmss}.htm", ReportTitle, CityName, Global.Now());
                    Global.SysUtil.Log("Generating Report: " + FileName);

                    HTMLBody = GetHTMLBody();

                    // Save Report to File
                    SaveReportToFile(FileName, HTMLBody);

                    // Send Report E-mail
                    toRecipients.Clear();
                    ccRecipients.Clear();

                    toRecipients.Add(CityDB.GetCityServiceGroupEmail((CityDB.CityEnum)i));

                    string[] SystemAdmins = TeacherDB.GetSystemAdmin();
                    foreach (var SystemAdmin in SystemAdmins)
                        ccRecipients.Add(SystemAdmin);

                    ccRecipients.Add("aic-lt@jq-edu.com");
                    ccRecipients.Add("wai.cheng@jq-edu.com");

                    SubjectID = CityName;
                    Global.SysUtil.SendHTML(toRecipients, ccRecipients, GetSubject(), HTMLBody);
                }
            }
        }
    }
}
